﻿namespace RayD.Core
{
    /// <summary>
    /// 缓存帮助类
    /// </summary>
    public class CacheHelper
    {

        /// <summary>
        /// 静态构造函数，初始化缓存类型
        /// </summary>
        static CacheHelper()
        {
            LocalCache = new LocalCache();

            RedisCache = new RedisCache(AppSettings.Redis.ConnectionString);

            if (!AppSettings.Redis.ConnectionString.IsEmpty())
            {
                Cache = RedisCache;
            }
            else
            {
                Cache = LocalCache;
            }
        }

        /// <summary>
        /// 默认缓存
        /// </summary>
        public static ICache Cache { get; }

        /// <summary>
        /// 系统缓存
        /// </summary>
        public static ICache LocalCache { get; }

        /// <summary>
        /// Redis缓存
        /// </summary>
        public static ICache RedisCache { get; }
    }
}
